﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication3
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
            this.skinEngine1 = new Sunisoft.IrisSkin.SkinEngine(((System.ComponentModel.Component)(this)));
            this.skinEngine1.SkinFile = Application.StartupPath + "//Calmness.ssk";
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            //根据编号修改数据+


            string user = textBox1.Text;
            string pwd = textBox2.Text;
            string sex = textBox3.Text;
            string birth = textBox4.Text;
            string add = textBox5.Text;
            string code = textBox6.Text;
            //创建数据库连接类的对象
            SqlConnection con = new SqlConnection("server=.;database=data1220;user=sa;pwd=123456");
            con.Open();
            //执行con对象的函数，返回一个SqlCommand类型的对象
            SqlCommand cmd = con.CreateCommand();
            //拼写语句
            cmd.CommandText = "update users set name='"+user+"',pwd='"+pwd+"' ,sex='"+sex+"',birth='"+birth+"',addresss='"+add+"'where code="+code;
            //增删改用ExecuteNonQuery，会返回一个整型数字
            int count = cmd.ExecuteNonQuery();
            if (count > 0)
            {
                MessageBox.Show("修改成功");
            }
            else
            {
                MessageBox.Show("修改失败");
            }
            con.Close();
        }
    }
}
